package com.byb.server.service.mapper.Wc;


import com.byb.server.domain.WcProduct;
import com.byb.server.service.dto.Wc.WcSearchProductDTO;
import com.byb.server.service.mapper.EntityMapper;
import com.byb.server.service.mapper.WcInsuranceCategoryMapper;
import com.byb.server.service.mapper.WcIsurerMapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * Mapper for the entity WcProduct and its DTO WcProductDTO.
 */
@Mapper(componentModel = "spring", uses = {WcIsurerMapper.class, WcInsuranceCategoryMapper.class, })
public interface WcSearchProductMapper extends EntityMapper<WcSearchProductDTO, WcProduct> {

    @Mapping(source = "wcIsurer.id", target = "wcIsurerId")
    @Mapping(source = "wcIsurer.name", target = "wcIsurerName")

    @Mapping(source = "wcInsuranceCategory.id", target = "wcInsuranceCategoryId")
    @Mapping(source = "wcInsuranceCategory.name", target = "wcInsuranceCategoryName")
    WcSearchProductDTO toDto(WcProduct wcProduct);

    @Mapping(source = "wcIsurerId", target = "wcIsurer")

    @Mapping(source = "wcInsuranceCategoryId", target = "wcInsuranceCategory")
    WcProduct toEntity(WcSearchProductDTO wcSearchProductDTO);
    default WcProduct fromId(Long id) {
        if (id == null) {
            return null;
        }
        WcProduct wcProduct = new WcProduct();
        wcProduct.setId(id);
        return wcProduct;
    }
}
